package com.wangziyu.facerecognitiongate.printer

import android.util.Log

/**
 * @description [描述信息]
 * @author wzy
 * @date 2025/09/04 23:50:23
 */
data object Demo {
    fun demo() {
        // 58mm 小票，整行 32 字符
        val printer = ReceiptPrinter(
            lineWidth = 32, columnWidths = listOf(16, 8, 8), // 商品名16，数量8，单价8
            aligns = listOf(
                ReceiptPrinter.Align.LEFT, ReceiptPrinter.Align.CENTER, ReceiptPrinter.Align.RIGHT
            )
        )

        val sb = StringBuffer()
        sb.append(printer.formatRow(listOf("商品", "数量", "单价")))
        sb.append(printer.divider())

        val items = listOf(
            listOf("苹果", "2", "5.00"),
            listOf("香蕉", "100000000", "123456789.123"),
            listOf("进口火龙果特别甜特别好吃", "1", "25.00")
        )

        for (item in items) {
            sb.append(printer.formatRow(item))
        }

        sb.append(printer.divider())
        sb.append(printer.formatRow(listOf("合计", "", "55.00")))

        // 打印
        val receipt = sb.toString()
        Log.i("Demo", receipt)
    }
}